<template>
  <div class="login">
    <div class="top">
        <input type="text" v-model="name">
        <input type="password" v-model="pass">
        <button @click="login">登录</button>
    </div>
  </div>
</template>

<script>
import { ref, reactive, toRefs } from "vue";
import { useStore } from "vuex";
import { useRouter, useRoute } from "vue-router";
export default {
  setup(props, {emit}) {
    const store = useStore();
    const router = useRouter();
    const route = useRoute();
    const data = reactive({
        name: '',
        pass: ''
    });

    const login = () => {
        if (data.name === '' || data.pass === '') {
            alert('不能为空！')
            return false
        }else {
            router.push('/')
        }
    }

    return { ...toRefs(data), login };
  },
};
</script>

<style lang='scss'>
</style>
